import logger from '../dxmodules/dxLogger.js'
import code from '../dxmodules/dxCode.js'
import center from '../dxmodules/dxEventCenter.js'
import std from '../dxmodules/dxStd.js'

//Camera component handle id
const capturerId = 'capturer1'

//Decoding component handle id
const decoderId = 'decoder1'

//Initialize Transaction Center
center.init()

//QR code data after subscription camera decoder processing
center.on(code.CODE_CONTENT, function (data) {
    logger.info("The QR code content is:", data)
}, "service")


//Initialize camera parameters
let options1 = { id: capturerId, path: "/dev/video11" }

//Initialize decoder parameters
let options2 = { id: decoderId, name: "decoder v4", width: 800, height: 600 }

//start up
code.worker.beforeLoop(options1, options2)

std.setInterval(() => {
    code.worker.loop(options1, options2)
    center.getEvent()

}, 20)


